package com.lxy.aimin.mcp.server.config;

import com.lxy.aimin.mcp.server.service.WeatherService;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*
 *
 * @author 渣哥
 */
@Configuration
public class ToolsConfig {


    @Bean
    public ToolCallbackProvider toolConfig(WeatherService weatherService) {
        return MethodToolCallbackProvider.builder().toolObjects(weatherService).build();
    }

/*    @Bean
     public ToolCallbackProvider toolConfig(TableInfoTool tableInfoTool) {
         return MethodToolCallbackProvider.builder().toolObjects(tableInfoTool).build();
     }*/




/*    @Bean
    public List<McpServerFeatures.SyncResourceSpecification> myResources() {
        McpSchema.Annotations annotations = new McpSchema.Annotations(List.of(), 0.6d);
        var systemInfoResource = new McpSchema.Resource("http://localhost:8090/aimin-mcp/test/tableNames", "getTableNames", "获取全部表名以及表的注释", "json", annotations);
        var resourceSpecification = new McpServerFeatures.SyncResourceSpecification(systemInfoResource, (exchange, request) -> {
            try {
                var systemInfo = Map.of("info", "123");
                String jsonContent = new ObjectMapper().writeValueAsString(systemInfo);
                return new McpSchema.ReadResourceResult(
                        List.of(new McpSchema.TextResourceContents(request.uri(), "application/json", jsonContent)));
            } catch (Exception e) {
                throw new RuntimeException("Failed to generate system info", e);
            }
        });

        return List.of(resourceSpecification);
    }*/
}
